package com.yaojiaxun.logisticsPlatformSystem.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yaojiaxun.logisticsPlatformSystem.entity.ClientInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @Auther: yjx_j
 * @Date: 2019/2/12 13:25
 * @Description:
 */
@Mapper
public interface ClientInfoMapper extends BaseMapper<ClientInfo> {
    @Select("select * from client_info where client_id=#{clientId}")
    public ClientInfo selectClientById(@Param("clientId") Long clientId);

    @Delete("delete from client_info where client_id=#{clientId}")
    public void deleteClientById(@Param("clientId") Long clientId);

    @Insert("insert into client_info(client_id, client_account, client_password, client_name, client_phone, client_email, " +
            "client_qq, client_province, client_city, client_country, client_address, create_time, update_time) values (#{client.clientId}, " +
            "#{client.clientAccount}, #{client.clientPassword}, #{client.clientName}, #{client.clientPhone}, " +
            "#{client.clientEmail}, #{client.clientQq}, #{client.clientProvince}, #{client.clientCity}, #{client.clientCountry}, " +
            "#{client.clientAddress}, #{client.createTime}, #{client.updateTime})")
    public void insertClientInfo(@Param("client") ClientInfo client);

    @Update("update client_info set client_account=#{clientAccount}, client_password=#{clientPassword}, client_name=#{clientName}, " +
            "client_phone=#{clientPhone}, client_email=#{clientEmail}, client_qq=#{clientQq}, " +
            "client_province=#{clientProvince}, client_city=#{clientCity}, client_country=#{clientCountry}, client_address=#{clientAddress} " +
            "where client_id=#{clientId}")
    public Integer updateClientInfo(@RequestParam("clientInfo") ClientInfo clientInfo);

    @Select("select * from client_info where client_account=#{clientAccount}")
    public ClientInfo findClientInfoByAccount(@Param("clientAccount") String clientAccount);

    @Select("select * from client_info where client_phone=#{clientPhone}")
    public List<ClientInfo> findClientInfoByPhone(@Param("clientPhone") String clientPhone);

}
